#include <stdio.h>
#include "basiciff.h"

static unsigned char data[0x103];

void write_thrash(GroupContext *gc) {
  IFFP iffp;

  iffp = PutCk(gc, JUNK, sizeof(data), data);
  printf("iffp = %d $%X\n", iffp, iffp);  
}

int main() {
  int i;
  GroupContext gc;
  GroupContext gc2;
  FILE *f;
  IFFP iffp;

  for(i = 0; i < sizeof(data); ++i) data[i] = i & 0xFF;
  f = fopen("testfile.iff", "wb+");
  iffp = OpenWIFF(f, &gc, szNotYetKnown);
  printf("iffp = %d $%X\n", iffp, iffp);
  //
  iffp = StartWGroup(&gc, FORM, szNotYetKnown, MakeID('T', 'R', 'S', 'H'), &gc2);
  printf("iffp = %d $%X\n", iffp, iffp);
  write_thrash(&gc2);
  write_thrash(&gc2);
  write_thrash(&gc2);
  iffp = EndWGroup(&gc2);
  printf("iffp = %d $%X\n", iffp, iffp);
  //
  iffp = CloseWGroup(&gc);
  printf("iffp = %d $%X\n", iffp, iffp);
  (void) fclose(f);
  return 0;
}
